home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 580 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: tony@online.tmx.com.au (Tony Cook)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Is dynamic_cast safe?
  5. Date: 28 Feb 1996 09:30:38 PST
  6. Organization: Home
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <199602280545.QAA27432@online.tmx.com.au>
  9. References: <AD58B8389668E1A9@sleipner.nts.mh.se>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: Wed, 28 Feb 1996 16:45:15 +1100
  12. X-Newsreader: TIN [version 1.2 PL2]
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMTSR8ky4NqrwXLNJAQGsLgIAsmBzQXNnq/lb12foO5pCS6VYJkoTjpw7
  15.     w6Jd0bfiQPGMCugtptB/4YR0RqGOr+n6APfosGlVH2rEPkUMf8h7LA==
  16.     =2IVx
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. Lars Farm (lars.farm@nts.mh.se) wrote:
  20. :      5.2.6  Dynamic cast                           [expr.dynamic.cast]
  21. :    ...
  22. :    6 Otherwise,  v shall be a pointer to or an lvalue of a polymorphic type
  23. :    ...
  24. : What should happen when 'v' is not a pointer to or an lvalue of a
  25. : polymorphic type? return 0? crash? throw bad_cast? undefined?
  26.  
  27. No, the compiler should produce a diagnostic, see [intro.compliance]
  28. paragraphs 1 through 3.
  29.  
  30. :    ...
  31. :    8 The  run-time  check  logically  executes  like  this: 
  32. :      [...]  Otherwise, the run-time  check fails.
  33.  
  34. : If fail means undefined, why not require that it returns 0?
  35.  
  36. This one is made pretty clear in the following paragraph:
  37.  
  38. 9 The value of a failed cast to pointer type is the null pointer value
  39.   of the required result type.  A failed cast to reference type throws
  40.   bad_cast (_lib.bad.cast_).
  41.  
  42. -- 
  43.         Tony Cook - tony@online.tmx.com.au
  44.                     100237.3425@compuserve.com
  45. ---
  46. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  47.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  48.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  49.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  50.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  51. ]
  52.